const http =require('http')
// http://www.itying.com/api/plist
function formatApi(api){
    return "http://www.itying.com/"+ api
}
http.createServer((req,res)=>{

    console.log(req.url) //获取url

    //设置响应头 状态是200 文件类型是html  字符集是 utf8
    res.writeHead(200,{"Content-type":"text/html;charset='utf-8'"})
    
    res.write("<head><meta charset='UTF-8'></head>")//防止中文乱码
    
    res.write('this is node.js');

    res.write('你好 node.js<br>');
    var api=formatApi('api/plis');
    res.write(api);

    res.end();//结束响应 必须写

}).listen(3000)//监听3000端口